package com.xiaotou.db.pojo;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import org.hibernate.annotations.Filter;

@Entity
public class ActionTask implements Serializable {

	private static final long serialVersionUID = -8501955816187514263L;

	public static final int PENDING_STATE = 0;
	public static final int ACTION_STATE = 2;
	public static final int DONE_STATE = 4;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;

	private int availableMoney;

	@Column(nullable = true)
	private Integer gotMoney;

	private Date createTime;
	private Date actionTime;
	private Date doneTime;
	private int state;

	private int partnersThreshold;

	private String snapshot;

	@ManyToOne(fetch = FetchType.LAZY)
	private WbUser thief;

	@ManyToOne(fetch = FetchType.LAZY)
	private WbUser prey;

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "actionTask")
	@Filter(name = "partnerType", condition = "type = 'partner'")
	private Set<ActionMember> partners;

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "actionTask")
	@Filter(name = "crowType", condition = "type = 'crow'")
	private Set<ActionMember> crow;

	public Set<ActionMember> getPartners() {
		return partners;
	}

	public void setPartners(Set<ActionMember> partners) {
		this.partners = partners;
	}

	public Set<ActionMember> getCrow() {
		return crow;
	}

	public void setCrow(Set<ActionMember> crow) {
		this.crow = crow;
	}

	public WbUser getThief() {
		return thief;
	}

	public void setThief(WbUser thief) {
		this.thief = thief;
	}

	public WbUser getPrey() {
		return prey;
	}

	public void setPrey(WbUser prey) {
		this.prey = prey;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Date getActionTime() {
		return actionTime;
	}

	public void setActionTime(Date actionTime) {
		this.actionTime = actionTime;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public int getPartnersThreshold() {
		return partnersThreshold;
	}

	public void setPartnersThreshold(int memberSumThreshold) {
		this.partnersThreshold = memberSumThreshold;
	}

	public Integer getGotMoney() {
		return gotMoney;
	}

	public void setGotMoney(Integer gotMoney) {
		this.gotMoney = gotMoney;
	}

	public String getSnapshot() {
		return snapshot;
	}

	public void setSnapshot(String snapshot) {
		this.snapshot = snapshot;
	}

	public int getState() {
		return state;
	}

	public void setState(int state) {
		this.state = state;
	}

	public Date getDoneTime() {
		return doneTime;
	}

	public void setDoneTime(Date doneTime) {
		this.doneTime = doneTime;
	}

	public int getAvailableMoney() {
		return availableMoney;
	}

	public void setAvailableMoney(int availableMoney) {
		this.availableMoney = availableMoney;
	}
}
